/* GUI CONVERTED from rccciq.p (converter v1.75) Tue Apr 10 12:03:26 2001 */
/* rccciq.p - Release Management Customer Schedules                           */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.7.1.4 $                                                           */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 7.3     LAST MODIFIED: 10/09/92    BY: WUG *G462*                */
/* REVISION: 7.3     LAST MODIFIED: 10/18/93    BY: WUG *GG36*                */
/* REVISION: 7.3     LAST MODIFIED: 03/29/95    BY: bcm *G0JS*                */
/* REVISION: 8.6E    LAST MODIFIED: 02/23/98    BY: *L007* A. Rahane          */
/* REVISION: 8.6E    LAST MODIFIED: 02/26/98    BY: *K1JW* Beena Mol          */
/* REVISION: 8.6E    LAST MODIFIED: 10/04/98    BY: *J314* Alfred Tan         */
/* REVISION: 9.1     LAST MODIFIED: 03/24/00    BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1     LAST MODIFIED: 08/12/00    BY: *N0KP* Mark Brown         */
/* REVISION: 9.1     LAST MODIFIED: 09/05/00    BY: *N0R9* BalbeerS Rajput    */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.7.1.4 $    BY: Jean Miller    DATE: 03/22/01 ECO: *P008*          */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

/* CUSTOMER CALENDAR INQUIRY */

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rccciq_p_8 "Customer/Ship-To"
/* MaxLen: Comment: */

&SCOPED-DEFINE rccciq_p_10 "Description"
/* MaxLen: Comment: */

&SCOPED-DEFINE rccciq_p_11 " Operating Day Hour Exceptions "
/* MaxLen: Comment: */

&SCOPED-DEFINE rccciq_p_12 " Non-Operating Days "
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define variable site   as   character label {&rccciq_p_8}.
define variable frdate like oa_fr_date initial today.

define variable dname  as   character extent 7 format "x(10)".
define variable i      as   integer.
define variable w-days as character no-undo.

define buffer caldet for cal_det.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   site
   ad_name no-label
   frdate
with frame a no-underline width 80 attr-space THREE-D /*GUI*/.

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

FORM /*GUI*/ 
   space(1)
   dname[1] no-label
   dname[2] no-label
   dname[3] no-label
   dname[4] no-label
   dname[5] no-label
   dname[6] no-label
   dname[7] no-label
   skip(0) space(1)
   shop_hours[1] no-label
   shop_hours[2] no-label
   shop_hours[3] no-label
   shop_hours[4] no-label
   shop_hours[5] no-label
   shop_hours[6] no-label
   shop_hours[7] no-label
with STREAM-IO /*GUI*/  frame b side-labels width 80 no-attr-space.

dname[1] = getTermLabel("SUNDAY",10).
dname[2] = getTermLabel("MONDAY",10).
dname[3] = getTermLabel("TUESDAY",10).
dname[4] = getTermLabel("WEDNESDAY",10).
dname[5] = getTermLabel("THURSDAY",10).
dname[6] = getTermLabel("FRIDAY",10).
dname[7] = getTermLabel("SATURDAY",10).

w-days   = dname[1] + "," + dname[2] + "," + dname[3] + "," +
           dname[4] + "," + dname[5] + "," + dname[6] + "," + dname[7].

site = global_site.

{wbrp01.i}

repeat:

   if c-application-mode <> "WEB" then
      update
        site
        frdate
      with frame a editing:

      if frame-field = "site" then do:
         {mfnp05.i ls_mstr ls_addr "ls_type = ""custcal"""
            ls_addr "input site"}
         if recno <> ? then do:
            find ad_mstr where ad_addr = ls_addr no-lock no-error.
            display
               ls_addr @ site
               ad_name
            with frame a.
         end.
      end.
      else do:
         status input.
         readkey.
         apply lastkey.
      end.
   end.

   status input.

   {wbrp06.i &command = update &fields = "  site frdate" &frm = "a"}

   if (c-application-mode <> "WEB") or
      (c-application-mode = "WEB" and
      (c-web-request begins "DATA"))
   then do:

      hide frame c.
      hide frame h.

      find ad_mstr where ad_addr = site no-lock no-error.

      display
         ad_name when (available ad_mstr)
         "" when (not available ad_mstr) @ ad_name
      with frame a.

      find ls_mstr where ls_type = "custcal" and ls_addr = site
      no-lock no-error.

      if not available ls_mstr then do:
         {pxmsg.i &MSGNUM=5910 &ERRORLEVEL=3}
         /* Address List Type not Created */
         if c-application-mode = "WEB" then return.
         else next.
      end.

      hide frame b no-pause.
      hide frame c no-pause.

   end.

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "terminal"
               &printWidth = 80
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "no"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}

   find shop_cal
   where shop_site = site
     and shop_wkctr = ""
     and shop_mch = ""
   no-lock no-error.

   if available shop_cal then do:

      do i = 1 to 7:
         display
            dname[i]
         with frame b STREAM-IO /*GUI*/ .
         if shop_wdays[i] then
         display
            shop_hours[i]
         with frame b STREAM-IO /*GUI*/ .
         else
         display
            shop_wdays[i] @ shop_hours[i]
         with frame b STREAM-IO /*GUI*/ .
      end.

      for each cal_det no-lock
         where cal_site = shop_site
           and cal_wkctr = shop_wkctr and cal_mch = shop_mch
           and (cal_end >= frdate or cal_end = ? or frdate = ?)
      break by cal_site by cal_wkctr by cal_mch by cal_ref
      with frame c:

         FORM /*GUI*/ 
         with STREAM-IO /*GUI*/  frame c
         title color normal (getFrameTitle("OPERATING_DAY_HOUR_EXCEPTIONS",41))
         no-attr-space width 80.

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame c:handle).

         if first-of (cal_ref) then do with frame c:

            find caldet where
                 caldet.cal_site = cal_det.cal_site
             and caldet.cal_wkctr = cal_det.cal_wkctr
             and caldet.cal_mch = cal_det.cal_mch
             and caldet.cal_ref = cal_det.cal_ref
             and caldet.cal_start = ?
             and (caldet.cal_end >= frdate
               or caldet.cal_end = ? or frdate = ?)
            no-lock no-error.

            if available caldet then do with frame c:
               display
                  caldet.cal_ref @ cal_det.cal_ref
                  caldet.cal_start @ cal_det.cal_start
                  caldet.cal_end @ cal_det.cal_end
                  caldet.cal_hours @ cal_det.cal_hours WITH STREAM-IO /*GUI*/ .
               if not can-find (caldet where
                                caldet.cal_site = cal_det.cal_site
                            and caldet.cal_wkctr = cal_det.cal_wkctr
                            and caldet.cal_mch = cal_det.cal_mch
                            and caldet.cal_ref = cal_det.cal_ref)
               then
                  down 1.
            end.

            for each caldet no-lock where
                     caldet.cal_site = cal_det.cal_site
                 and caldet.cal_wkctr = cal_det.cal_wkctr
                 and caldet.cal_mch = cal_det.cal_mch
                 and caldet.cal_ref = cal_det.cal_ref
                 and caldet.cal_start <> ?
                 and (caldet.cal_end >= frdate
                  or caldet.cal_end = ? or frdate = ?)
            break by caldet.cal_site
            with frame c:

               display
                  caldet.cal_ref @ cal_det.cal_ref
                  caldet.cal_start @ cal_det.cal_start
                  caldet.cal_end @ cal_det.cal_end
                  caldet.cal_hours @ cal_det.cal_hours WITH STREAM-IO /*GUI*/ .
               if last-of (caldet.cal_site) = no
               then
                  down 1.
            end.

         end. /* if first-of */

      end. /* for each cal_det */

      for each hd_mstr
         where hd_site = shop_site and
               hd_date >= frdate
      no-lock with frame h:

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame h:handle).

         display
            hd_date
            hd_desc label {&rccciq_p_10}
            string(entry(weekday(hd_date),w-days))
            format "x(10)" no-label
         with title color normal (getFrameTitle("NON-OPERATING_DAYS",26))
         width 80 STREAM-IO /*GUI*/ .

      end.

   end.

   {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

   {pxmsg.i &MSGNUM=8 &ERRORLEVEL=1}

end.

{wbrp04.i &frame-spec = a}
